import React, {
    Component,
    PropTypes
} from 'react';

import {
    MapView, 
    MapTypes, 
    Geolocation 
} from 'react-native-baidu-map';

import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    TouchableHighlight
} from 'react-native';
import UserStateInformation from './userStateInformation.js';
import UserActionInformation from './userActionInformation.js';
var userState = new UserStateInformation();
var userAction = new UserActionInformation();
//import styles from './styles';

export default class BaiduMap extends Component {

    constructor() {
        super();

        this.state = {
            mayType: MapTypes.NORMAL,
            zoom: 15, 
            trafficEnabled: false,
            baiduHeatMapEnabled: false,
        };
    }

    async componentDidMount() { // 获取位置
        await Geolocation.getCurrentPosition().then(
            (data) => {
                console.log("data----------"+JSON.stringify(data));
                userAction.myLatitude = data.latitude;
                userAction.myLongitude = data.longitude;
                
            }
        ).catch(error => {
            console.warn(error,'error')
        });
        
    }

    render() {
        
        return (
            <View >
                <MapView
                    trafficEnabled={this.state.trafficEnabled}
                    baiduHeatMapEnabled={this.state.baiduHeatMapEnabled}
                    zoom={this.state.zoom}
                    mapType={this.state.mapType}
                    center={this.state.center}
                    marker={this.state.marker}
                    markers={this.state.markers}
                   
                    onMapClick={(e) => {
                    }}
                >
                </MapView>

            </View>
        );
    }
}